import java.io.DataInput; 
import java.io.DataOutput; 
import java.io.IOException; 
import java.net.MalformedURLException; 
import java.net.URL; 
  
import org.apache.hadoop.io.Writable; 
  
class URLWritable implements Writable { 
  protected URL url; 
     
  public URLWritable() { url = null; } 
  
  public URLWritable(String s) throws MalformedURLException { 
    this.url = new URL(s); 
  } 
  
  @Override   
  public void write(DataOutput out) throws IOException { 
    out.writeUTF(url.toString()); 
  } 
  
  @Override 
  public void readFields(DataInput in) throws IOException { 
    url = new URL(in.readUTF()); 
  } 
  
  public void set(String s) throws MalformedURLException { 
    url = new URL(s); 
  } 
}
